Skip to content

fix: Resolve Firebase Not Initializing in Production - Issue #284#287

Open
NithinRegidi wants to merge 3 commits intoeccentriccoder01:mainfrom
NithinRegidi:fix/firebase-initialization-issue-284
Open

fix: Resolve Firebase Not Initializing in Production - Issue #284#287
NithinRegidi wants to merge 3 commits intoeccentriccoder01:mainfrom
NithinRegidi:fix/firebase-initialization-issue-284

Conversation

@NithinRegidi
Copy link

Which issue does this PR close?

Rationale for this change

Firebase was failing to initialize in production because the application was using hardcoded API keys and import.meta.env (which doesn't work in browser environments). This caused authentication and database features to break on pages like profile, proposals, and create-proposal.

What changes are included in this PR?

  • Added secure Firebase config serving: Created /api/config endpoint in server.js to serve Firebase configuration from environment variables
  • Created client-side config loader: Added scripts/env.js to load Firebase config from the server API before Firebase initialization
  • Updated Firebase scripts: Modified scripts/firebase-config.js to use window.firebaseConfig instead of import.meta.env
  • Fixed script loading order: Added env.js includes to all Firebase-dependent HTML files (profile.html, proposals.html, forgot-password.html, login.html, register.html, create-proposal.html)
  • Updated security policies: Modified CSP in server.js to allow Firebase source map requests
  • Documentation updates: Enhanced .env.example with architecture explanation and setup instructions
  • Git configuration: Removed env.js from .gitignore to track the new file

Are these changes tested?

Yes, changes were tested locally:

  • Server starts without Firebase errors
  • /api/config endpoint returns complete Firebase configuration
  • HTML pages load with correct script order
  • No CSP violations for Firebase requests
  • Environment variables load securely without exposing keys

Are there any user-facing changes?

No breaking changes. Users will now have working Firebase authentication and database features on all pages that previously failed. The changes are internal and improve reliability without affecting the UI or user experience.

Removed Hardcoded API Keys from the project codebase, because it is open to everyone to make use of it.

Screenshot 2026-02-12 114613

Clean console errors by fixing Firebase initialization and CSP violations

Screenshot 2026-02-12 125309 Screenshot 2026-02-12 125436

@vercel
Copy link

vercel bot commented Feb 12, 2026

@NithinRegidi is attempting to deploy a commit to the eccentriccoder01's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

@NithinRegidi
Copy link
Author

@eccentriccoder01 Please review this PR Once.

@vercel
Copy link

vercel bot commented Feb 15, 2026

Deployment failed with the following error:

If `rewrites`, `redirects`, `headers`, `cleanUrls` or `trailingSlash` are used, then `routes` cannot be present.

Learn More: https://vercel.link/mix-routing-props

@eccentriccoder01 eccentriccoder01 added bug Something isn't working medium apertre3.0 labels Feb 15, 2026
@eccentriccoder01
Copy link
Owner

Deployment failed with the following error:

If `rewrites`, `redirects`, `headers`, `cleanUrls` or `trailingSlash` are used, then `routes` cannot be present.

Learn More: https://vercel.link/mix-routing-props

@NithinRegidi Kindly look into the vercel-specific preview-deployment route error and fix 'em... Routes and Redirects cannot be used together...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apertre3.0 bug Something isn't working medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Critical: Firebase Not Initializing in Production - Auth and Database Failing

2 participants